//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<XEditDesktop.h>
///	@path	~/src/editor/xedit/
///	@date	2008/08/29
///	@desc	.

#include "xeres.h"

#include "gui/xgui/XDesktop.h"

#include <map>

namespace xeres {

	/*! 
		\class	XEditDesktop
		\brief
	*/
	class XEditDesktop : public XDesktop
	{
	public:

		/// \ctor
		XEditDesktop( void );

		/// \dtor
		virtual ~XEditDesktop( void );

		DECL_IOBJECT_CLASS( XEditDesktop , XDesktop );

	public:

		/// \name Desktop Attributes
		//@{

		/// \brief	Get desktop origin point.
		virtual Pair<int> GetDesktopOrigin( void );

		/// \brief	Get desktop area.
		virtual Rect<int> GetDesktopArea( void );

		/// \brief	Get focusing area.
		virtual Rect<int> GetFocusArea( void );

		/// \brief	Get input focus.
		virtual RefWeak<IGuiComp> GetInputFocus( void );

		/// \brief	Set desktop origin point.
		virtual void SetDesktopOrigin( const Pair<int>& org );

		/// \brief	Set desktop size.
		virtual void SetDesktopSize( const Pair<int>& size );

		/// \brief	Attach frame.
		virtual void Attach( RefWeak<XFrame> frame );

		/// \brief	Detach form.
		virtual void Detach( RefWeak<XFrame> frame );

		//@}

		/// \name Window Management
		//@{

		/// \brief	Show window.
		virtual void ShowWindow( RefWeak<XFrame> form , bool hide , bool animate );

		/// \brief	Pin window to top.
		virtual void PinWindow( RefWeak<XFrame> form , bool pin );

		//@}

		/// \name Message Passing
		//@{

		///	\brief	Process key input message.
		virtual HandleInput OnKeyInput( Updater& updater );

		///	\brief	Process mouse input message.
		virtual HandleInput OnMouseInput( Updater& updater );

		//@}

		/// \name Presentation Manipulation
		//@{

		/// \brief	Tick update.
		virtual void Tick( Updater& updater , float dTime );

		/// \brief	Draw XGUI component to composition.
		virtual void Draw( Composition& composition );

		//@}

		/// \name XGUI Form Interface
		//@{

		/// \brief	Clear focus.
		virtual void ClearFocus( Updater& updater );

		///	\brief	Get focus component.
		virtual RefWeak<IGuiComp> GetFocusing( void );

		/// \brief	Enter input mode.
		virtual void EnterInputMode( RefWeak<IGuiComp> comp , Updater& updater );

		/// \brief	Get input mode.
		virtual bool GetInputMode( void );

		/// \brief	Add child component.
		virtual bool AddChild( RefWeak<IGuiComp> comp );

		/// \brief	Del child component.
		virtual bool DelChild( RefWeak<IGuiComp> comp );

		/// \brief	Add tickable child.
		virtual void AddTickable( RefWeak<IGuiComp> comp );

		/// \brief	Del tickable child.
		virtual void DelTickable( RefWeak<IGuiComp> comp );

		/// \brief	Request focus.
		virtual void RequestFocus( RefWeak<IGuiComp> comp , Updater& updater );

		//@}

		/// \name XGui Component Attributes
		//@{

		/// \brief	Get position of component (in relative coordinate).
		virtual Pair<int> GetPosition( void );

		/// \brief	Set position of component.
		virtual bool SetPosition( const Pair<int>& pos );

		/// \brief	Get size of component.
		virtual Pair<int> GetSize( void );

		/// \brief	Set size of component.
		virtual bool SetSize( const Pair<int>& size );

		/// \brief	Set placement.
		virtual bool SetPlacement( const Rect<int>& placement );

		/// \brief	Get placement rect.
		virtual Rect<int> GetPlacement( void );

		/// \brief	Get component visibility.
		virtual bool GetVisible( void );

		/// \brief	Set component visibility.
		virtual bool SetVisible( bool visible );

		/// \brief	Get component enable (to input).
		virtual bool GetEnable( void );

		/// \brief	Set component enable.
		virtual bool SetEnable( bool enable );

		/// \brief	Get focus state.
		virtual bool GetFocus( void );

		/// \brief	Set focus state.
		virtual bool SetFocus( bool focus );

		/// \brief	Hit test.
		virtual bool HitTest( const Pair<int>& pt );

		//@}

	private:

		// @data

		// main frame
		HWND									m_mainFrm;

		// root frames
		std::map< uint32 , Ref< XFrame > >	m_frameMap;

		// frame order
		std::deque< RefWeak< XFrame > >		m_frameOrder;

		// focusing form
		RefWeak< XFrame >						m_focusing;

	};

} // namespace xeres
